package com.yld.demo2.mapper;

import com.yld.demo2.entity.table.OrderList;
import com.yld.demo2.entity.vo.OrderListVo;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface OrderListMapper {

    @Select("select * from order_list where user_id = #{userid}")
    OrderListVo selectByUserId(@Param("user_id") Integer userid);

    @Select("select * from order_list")
    List<OrderListVo> selectAll();

    @Insert("insert into order_list (order_no,user_id,prod_id,order_num,amout,order_date) values (#{orderno},#{userid},#{prodid},#{ordernum},#{amout},#{orderdate})")
    Boolean insertAll(OrderListVo orderListVo);

    @Delete("delete from order_list where order_no = #{order_no}")
    Boolean deleteByOrderNo(@Param("order_no") Integer orderno);

    @Update("update order_list set user_id=#{userid}, prod_id=#{prodid}, order_num=#{ordernum}, amout=#{amout}, order_date=#{orderdate}" +
            "where order_no=#{orderno}")
    Boolean updateByOrderNo(OrderListVo orderListVo);

    @Select("select * from order_list where user_id = #{userid}" )
    List<OrderListVo> selectAllByUserId(Integer userid);

    @Select("select user_id from order_list where order_no = #{orderno}")
    Integer selectUserIdByOrderno(Integer orderno);
}
